package coml.jiyun.hp.wanandroid.ui.fragment;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.List;

import butterknife.BindView;
import coml.jiyun.hp.wanandroid.R;
import coml.jiyun.hp.wanandroid.base.BaseLazyFragment;
import coml.jiyun.hp.wanandroid.bean.SquareBean;
import coml.jiyun.hp.wanandroid.presenter.SquarePresenter;
import coml.jiyun.hp.wanandroid.ui.adapter.RlvSquareAdapter;
import coml.jiyun.hp.wanandroid.view.SquareView;

/**
 * A simple {@link Fragment} subclass.
 */
public class SquareFragment extends BaseLazyFragment<SquarePresenter>implements SquareView {


    @BindView(R.id.square_rlv)
    RecyclerView mRlv;
    private RlvSquareAdapter rlvSquareAdapter;

    public SquareFragment() {
        // Required empty public constructor
    }

    @Override
    protected void initListener() {
        mPresenter.getSquare();
    }

    @Override
    protected void initData() {
        mPresenter.getSquare();
    }

    @Override
    protected SquarePresenter initPresenter() {
        return new SquarePresenter();
    }

    @Override
    protected void initView(View view) {
        mRlv.setLayoutManager(new LinearLayoutManager(getActivity()));
        rlvSquareAdapter = new RlvSquareAdapter(getActivity());
        mRlv.setAdapter(rlvSquareAdapter);

    }

    @Override
    protected int getLayout() {
        return R.layout.fragment_square;
    }

    @Override
    public void getSquare(SquareBean squareBean) {
        List<SquareBean.DataBean.DatasBean> datas = squareBean.getData().getDatas();
        rlvSquareAdapter.setDatasBeans(datas);
        rlvSquareAdapter.notifyDataSetChanged();
    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }
}
